package com.light.common.base;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import lombok.Data;

/**
 * @Tittle BaseQuery
 * @Description
 * @Author yhr
 * @Date 2019/4/3 15:10
 * @Version 1.0
 */
@Data
public abstract class BaseQuery<T> {
    /**
     * 当前页
     */
    private Integer currentPage = 1;

    @ApiParam(hidden = true)
    private Integer offset;
    /**
     * 每页条数
     */
    private Integer limit = 10;

    /**
     * 按'sort'排序
     */
    @ApiParam(hidden = true)
    private String sort;

    /**
     * 正序还是倒序
     */
    @ApiModelProperty("排序字段（不传为正序，\"DESC\"为倒序）")
    private String order;

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
        offset = (currentPage - 1) * limit;
    }

    public abstract QueryWrapper<T> createQueryWrapper();
}
